# -*- coding: utf-8 -*-
# @Date   : 2019/11/8
# @File   : IC27_DataIsNull.py
# @Author : zhaochen

'''eof
name:个人征信数据是否异常
code:IC27_DataIsNull_2D
tableName:
columnName:
groups:个人征信模块
dependencies:IC_DSJ_2D
type:常用指标
datasourceType:在线指标
description:
eof'''

import sys

reload(sys)
sys.setdefaultencoding('utf-8')

null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--']


def getTable(data, tableName, occurTimes):
    '''
        获取表信息
        :param data:表上层的字典对象
        :param tableName:表的名字
        :param occurTimes:表出现的次数，如果是0代表此表可以不出现，如果是1代表此表必须出现
        :return:该表全部数据
        '''
    table = data.get(tableName)
    if occurTimes == 0:
        if table is None:
            return [{}]
        elif isinstance(table, list) is False or len(table) == 0:
            return None
        else:
            return data.get(tableName)
    if occurTimes == 1:
        if table is None or isinstance(table, list) is False or len(table) == 0:
            return None
        elif len(table) == 0:
            return [{}]
        else:
            return data.get(tableName)


# def IC27_DataIsNull():
#     '''判断QueryReq 表中 reportNo  是否缺失'''
#
#     try:
#         QueryReq = getTable('QueryReq')
#         if QueryReq is None:
#             raise Exception(u'个人征信数据reportNo不存在')
#         else:
#             if QueryReq[0].get('reportNo') in null_type_list:
#                 raise Exception(u'个人征信数据reportNo不存在')
#             else:
#                 return 0
#     except:
#         raise Exception(u'个人征信数据reportNo不存在')


def IC27_DataIsNull():

    return 0



result = IC27_DataIsNull()
